Function: icalendar-date-time<

icalendar-date-time< is a byte-compiled function defined in icalendar-utils.el.gz.

Signature

(icalendar-date-time< DT1 DT2)

Documentation

Return non-nil if date-time DT1 is strictly earlier than DT2.

DT1 and DT2 must both be decoded times, and either both or neither should have time zone information.

If one has a time zone offset and the other does not, the offset returned from current-time-zone is used as the missing offset; if current-time-zone cannot provide this information, an error is signaled.

Source Code

;; Defined in /usr/src/emacs/lisp/calendar/icalendar-utils.el.gz
(defun ical:date-time< (dt1 dt2)
  "Return non-nil if date-time DT1 is strictly earlier than DT2.

DT1 and DT2 must both be decoded times, and either both or neither
should have time zone information.

If one has a time zone offset and the other does not, the offset
returned from `current-time-zone' is used as the missing offset; if
`current-time-zone' cannot provide this information, an error is
signaled."
  (let ((zone1 (decoded-time-zone dt1))
        (zone2 (decoded-time-zone dt2)))
    (cond ((and zone1 zone2)
           (time-less-p (encode-time dt1) (encode-time dt2)))
          ((and (null zone1) (null zone2))
           (ical:date-time-locally< dt1 dt2))
          (t
           ;; Cf. RFC5545 Sec. 3.3.5:
           ;; "The recipient of an iCalendar object with a property value
           ;; consisting of a local time, without any relative time zone
           ;; information, SHOULD interpret the value as being fixed to whatever
           ;; time zone the "ATTENDEE" is in at any given moment.  This means
           ;; that two "Attendees", in different time zones, receiving the same
           ;; event definition as a floating time, may be participating in the
           ;; event at different actual times.  Floating time SHOULD only be
           ;; used where that is the reasonable behavior."
           ;; I'm interpreting this to mean that if we get here, where
           ;; one date-time has zone information and the other doesn't,
           ;; we should use the offset from (current-time-zone).
           (let* ((user-tz (current-time-zone))
                  (user-offset (car user-tz))
                  (dt1z (ical:date-time-variant dt1 :zone (or zone1 user-offset)))
                  (dt2z (ical:date-time-variant dt2 :zone (or zone2 user-offset))))
             (if user-offset
                 (time-less-p (encode-time dt1z) (encode-time dt2z))
               (error "Too little zone information for comparison: %s %s"
                      dt1 dt2)))))))